<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
	<head>
		<title>工序汇报</title>
		<t:base type="jquery,easyui,tools,DatePicker,utils,yongxin2_js,yongxin_css,mobile_css"></t:base>
	</head>

<script>
 	$(function(){
 			$.ajax({
				type : "POST",
				url : "processReport10Controller.do?getProcess&fbcph=${processReportPage.fbcph}",
				data: {},
				success : function(jsondata) {
						data = $.parseJSON(jsondata);
						var str ="";
						$(data.obj).each(function(i,j){
							//console.log(j);
							str +="<span class='progress'>"+j.typename+"("+j.fbcph+")</span>";
							if(i%6==0){
								str +="<br><br>";
							}
							str +="<span >-----></span>";
							//console.log(str);
						});
						//str +=data.msg;
						
						console.log(str);
						$('#div_process').html(str);
						$('#div_nprocess').html(data.msg);
						$("select[name='nprocess']").val('${processReportPage.nprocess}');
					}
			});
	
				$.ajax({
				type : "POST",
				url : "processReport10Controller.do?getProcess&fbcph=${processReportPage.fbcph}&id=fnprocess",
				data: {},
				success : function(jsondata) {
						data = $.parseJSON(jsondata);
						var str ="";
						$(data.obj).each(function(i,j){
							//console.log(j);
							
							str +="<span class='progress'>"+j.typename+"("+j.fbcph+")</span>";
							if(i%6==0){
								str +="<br><br>";
							}
							str +="<span >-----></span>";
							//console.log(str);
						});
						//str +=data.msg;
						console.log(str);
						
						$('.f_div_nprocess').each(function(i){
							$(this).html(data.msg);
							//$('.nprocess:not(:first)').val('over');
							$("select[name='fnprocess']").val('over');
						});
						
					}
			});
				
            var num = ${fn:length(productList)<=0 ? 2: fn:length(productList)+1};  //${fn:length(productList)}<=0 ? 2: ${fn:length(productList)};
		
			var lastCommunAddTr = $(".trRecords:last");

		   $("#add_btn").click(function() {                      //增加行
		   		
               var tr = $("#temp_tr_records").clone();
               tr.attr('id',tr.attr('id')+lpad(num+"",'0',2));
          		
          		tr.attr('class','trRecords');          		
           		
           		if("${processReportPage.fbcph}".indexOf("-")>0){
           		
           			tr.find("#ffjh").get(0).value ="${processReportPage.fbcph}"+lpad(num+"",'0',2);
           		}
           		else{
           			tr.find("#ffjh").get(0).value ="${processReportPage.fbcph}-"+lpad(num+"",'0',2);
           		}
           		
               tr.insertAfter(lastCommunAddTr);
               lastCommunAddTr = tr;
               num++;
               $('.nprocess:not(:first)').val('over');
            });
            
            $("#del_btn").click(function() {                     //删除行
              var delIndexs = new Array(0);
              
              $(".trRecords:gt(0)").each(function(i) {
              		
					if($(this).find("#ck").get(0).checked == true){
                  		delIndexs.splice(delIndexs.length,0,i);
                     	$(this).remove();
                    }
                });
                
                 $(".trRecords").each(function(i) {
                	
                	if($(".trRecords").length==1){
			   		//	$("#records_tr").find("#ffjh").get(0).value ="${processReportPage.fbcph}01";
			   			num=2;
			   		}
			   		else{
			   			if("${processReportPage.fbcph}".indexOf("-")>0){
			   				$(this).find("#ffjh").get(0).value ="${processReportPage.fbcph}"+lpad((i+1)+'','0',2);
			   			}	
			   			else{
			   				$(this).find("#ffjh").get(0).value ="${processReportPage.fbcph}-"+lpad((i+1)+'','0',2);
			   			}
			   			num=$(".trRecords").length+1;
			   		}
                 	lastCommunAddTr = $(this);
                });
            });
                
             if('${fn:length(productList)}' <= 0){
                
                if("${processReportPage.fbcph}".indexOf("-")>0 ){
                
            	$("#records_tr").find("#ffjh").get(0).value ="${processReportPage.fbcph}"+'01';
                 }
                else{
            	$("#records_tr").find("#ffjh").get(0).value ="${processReportPage.fbcph}-"+'01';
                }
             }
             
            $("#save_btn").click(function() {//复制一行
               top.$(".ui_state_highlight").hide();
               
               if( $('#fcczl').val() == ""){
                 tip("剩余重量不能为空");
                 $('#fcczl').focus();
                 return false;
               }
               ajaxdoForm('processReport10Controller.do?save&fstate=1','formobj');
            });
            
            
            $('#fcczl').change(function() {
               
             if( $('#fcczl').val() != ""){
               var a = $('#ftrzl').val();
               var b = $('#fcczl').val();
               a = parseInt(a,10);
               b  = parseInt(b,10);
               if(b > a){
                 tip("剩余重量不能大于投入重量");
                 $('#fcczl').focus();
                 return false;
               }
               $('#ftrzls').val((a - b).toFixed(2));
               }
            });
            
           selChange(); 
 	});
    
     function selChange(){

  var sel = $("#fworkshop").val();
  $.ajax({
		type : "POST",
		url : "processReportController.do?getMatchinegroupList&process=${processReportPage.cprocess}",
		data: {pid:$('#fworkshop').val()},
		success : function(jsondata) {
				data = $.parseJSON(jsondata);
				console.log(data);
				$('#fmatchinegroup').html(data.msg);
			  	$('#fmatchinegroup').val("${processReportPage.fmatchinegroup}");
			}
	});
	
}

 </script>

	<body  scroll="no">
		<div id="wrapper">
					<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" tiptype="1"
						action="processReport10Controller.do?save&fstate=2" beforeSubmit="checkCut">
						<input id="id" name="id" type="hidden" value="${processReportPage.id }">
						<input type="hidden" id="cprocess" name="cprocess" class="mytxt" ignore="ignore" value="${processReportPage.cprocess}">
						<table  cellpadding="0" cellspacing="1" class="formtable">
							<tr>
								<td align="center" colspan=11>
									<label class="Validform_label">
										纵剪工序汇报单
									</label>
								</td>
							</tr>
							<tr>
								<td align="center" colspan=11 style="background-color: white; padding: 20px">
									<div id="div_process"></div>
								</td>
							</tr>
							<tr style="display: none">
								<td align="center">
									<label class="Validform_label">
										制单时间
									</label>
								</td>
								<td class="value" colspan=10>
									<input class="mytxt" style="width: 140px" id="updateDate" name="updateDate" class="mytxt" ignore="ignore"
										value="<fmt:formatDate value='${processReportPage.updateDate}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/>" ReadOnly>
									<!-- 	<input class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width: 150px" id="createDate"
							name="createDate" class="mytxt"  ignore="ignore">   -->
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										生产车间
									</label>
								</td>
								<td class="value" colspan=10>
									<!--<t:dictSelect field="fworkshop" typeGroupCode="workshop" hasLabel="false"  defaultVal="${processReportPage.fworkshop}" extendJson="{id:sel2}"></t:dictSelect>
								-->
								    <select  id="fworkshop"  name="fworkshop" onchange="selChange()">
								     <c:forEach items="${workshopList}" var="workshop">
								        <option value="${workshop.id}"   <c:if test="${workshop.id==processReportPage.fworkshop}"> selected="selected"</c:if>>${workshop.name}</option>
								     </c:forEach>
								     </select>
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										班组
									</label>
								</td>
								<td class="value" colspan=10>
									 <t:dictSelect field="fworkgroup" typeGroupCode="team" hasLabel="false"  defaultVal="${processReportPage.fworkgroup}" extendJson="{id:sel2}"></t:dictSelect>
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										机组
									</label>
								</td>
								<td class="value" colspan=10>
									<!--<input id="fmatchinegroup" name="fmatchinegroup" style="width: 140px;" class="mytxt" ignore="ignore"
										value="${processReportPage.fmatchinegroup}">
								-->
								 <select id='fmatchinegroup' name='fmatchinegroup'><option value=''>请选择</option></select>
								</td>
							</tr>
							<tr style="display: none">
								<td align="center">
									<label class="Validform_label">
										制单人
									</label>
								</td>
								<td class="value" colspan=10>
									<input id="createBy" name="createBy" style="width: 140px;" class="mytxt" ignore="ignore" readOnly
										value="${processReportPage.createBy}">

								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										本厂批号
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入厚度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入宽度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入重量
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										产出厚度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										产出宽度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										剩余重量
									</label>
								</td>

								<td align="center">
									<label class="Validform_label">
										质量情况
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										下一工序
									</label>
								</td>
							</tr>

							<tr id="record_tr" class="trRecord">
								<td align="center" class="value">
									<input id="fbcph" name="fbcph" class="mytxt" ignore="ignore" value="${processReportPage.fbcph}" style="width: 120px"
										ReadOnly>
								</td>
								<td align="center" class="value">

									<input id="ftrhd" name="ftrhd" class="mytxt" ignore="ignore" value="${processReportPage.ftrhd}" ReadOnly>
								</td>
								<td align="center" class="value">
									<input id="ftrkd" name="ftrkd" class="mytxt" ignore="ignore" value="${processReportPage.ftrkd}" ReadOnly>
								</td>
								<td align="center" class="value">
									<input id="ftrzl" name="ftrzl" class="mytxt" ignore="ignore" value="${processReportPage.ftrzl}" ReadOnly>
								</td>
								<td align="center" class="value">

									<input id="fcchd" name="fcchd" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.fcchd}">
								</td>
								<td align="center" class="value">
									<input id="fcckd" name="fcckd" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.fcckd}">
								</td>
								<td align="center" class="value">
									<input id="fcczl" name="fcczl" class="mytxt" ignore="ignore" value="${processReportPage.fcczl}">
								</td>
								<td align="center" class="value">
									<input id="fnote" name="fnote" class="mytxt" ignore="ignore" value="${processReportPage.fnote}">
								</td>
								<td align="center" class="value">
									<div id="div_nprocess"></div>
								</td>
							</tr>
							<tr>
								<td align="center">
									<label class="Validform_label">
										本厂批号
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入厚度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入宽度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										投入重量
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										分卷号
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										分切宽度
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										分切重量
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										下一工序
									</label>
								</td>
								<td align="center">
									<label class="Validform_label">
										备注
									</label>
								</td>

							</tr>
                                
                             
							<c:if test="${fn:length(productList)  > 0 }">
								<c:forEach items="${productList}" var="poVal" varStatus="stuts">
									<tr id="records_tr" class="trRecords">
										<c:if test="${stuts.index==0}">
											<td align="center" class="value" rowspan=100>
												<input id="fbcph" name="fbcphs" class="mytxt" ignore="ignore" value="${processReportPage.fbcph}"
													style="width: 120px" ReadOnly>
											</td>

											<td align="center" class="value" rowspan=100>

												<input id="ftrhds" name="ftrhds" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ftrhd}">
												<input id="ids" name="ids" class="mytxt" ignore="ignore" type="hidden" value="${poVal.id}">
											</td>
											<td align="center" class="value" rowspan=100>
												<input id="ftrkds" name="ftrkds" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ftrkd}">
											</td>
											<td align="center" class="value" rowspan=100>
												<input id="ftrzls" name="ftrzls" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ftrzl}">
											</td>
										</c:if>
										<c:if test="${stuts.index ==0}">
											<td align="center" class="value">
												<input id="ffjhs" name="ffjhs" class="mytxt" ignore="ignore"  style="width: 120px;" value="${poVal.ffjh}">
											</td>
										</c:if>
										<c:if test="${stuts.index>0}">
											<td align="left" class="value">
												<input type="checkbox" id="ck">
												<input id="ffjh" name="ffjhs" class="mytxt" ignore="ignore"  style="width: 120px;" value="${poVal.ffjh}">
											</td>
										</c:if>
										<td align="center" class="value">
											<input id="ffqkd" name="ffqkds" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ffqkd}">
										</td>
										<td align="center" class="value">
											<input id="ffqzl" name="ffqzls" class="mytxt" ignore="ignore" dataType="d" value="${poVal.ffqzl}">
										</td>
									    <td align="center" class="value">
									    <div id="f_div_nprocess" class="f_div_nprocess"></div>
								        </td>
										<td align="center" class="value">
											<input id="fnote" name="fnotes" class="mytxt" ignore="ignore" value="${poVal.fnote}">
										</td>
									</tr>
								</c:forEach>
							</c:if>
                           

							<c:if test="${fn:length(productList) <= 0 }">   
							
								<tr id="records_tr" class="trRecords">
									<td align="center" class="value" rowspan=100>
										<input id="fbcph" name="fbcphs" class="mytxt" ignore="ignore" value="${processReportPage.fbcph}" style="width: 120px" ReadOnly>
									</td>
									<td align="center" class="value" rowspan=100>
										<input id="ftrhds" name="ftrhds" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.ftrhd}" >
										<input id="ids" name="ids" class="mytxt" ignore="ignore" type="hidden" >
									</td>
									<td align="center" class="value" rowspan=100>
										<input id="ftrkds" name="ftrkds" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.ftrkd}">
									</td>
									<td align="center" class="value" rowspan=100>
										<input id="ftrzls" name="ftrzls" class="mytxt" ignore="ignore" dataType="d" >
									</td>
									<td align="center" class="value">
										<input id="ffjh" name="ffjhs" class="mytxt" ignore="ignore" style="width: 120px;" >
									</td>
									<td align="center" class="value">
										<input id="ffqkd" name="ffqkds" class="mytxt" ignore="ignore" dataType="d" >
									</td>
									<td align="center" class="value">
										<input id="ffqzl" name="ffqzls" class="mytxt" ignore="ignore" dataType="d">
									</td>
								    <td align="center" class="value">
									    <div id="f_div_nprocess" class="f_div_nprocess"></div>
								    </td>
									<td align="center" class="value">
										<input id="fnote" name="fnotes" class="mytxt" ignore="ignore" >
									</td>
								</tr>
							</c:if>
						</table>
						
					</t:formvalid>
					<div id="dlg-buttons" >
						<table cellpadding="0" cellspacing="0" style="width: 100%">
							<tr>
								<td style="padding-top: 10px">
									<a href="#" class="easyui-linkbutton btn" iconCls="icon-save" id="save_btn">保存</a>
									<a href="#" class="easyui-linkbutton btn" iconCls="icon-add" id="add_btn">增加分切</a>
									<a href="#" class="easyui-linkbutton btn" iconCls="icon-del" id="del_btn">删除分切</a>
								</td>
							</tr>
						</table>
					</div>



					<table style="width: 600px; display: none" cellpadding="0" cellspacing="1">

						<tr id="temp_tr_records">
							<td align="left" class="value">
								<input type="checkbox" id="ck">
								<input id="ffjh" name="ffjhs" class="mytxt" ignore="ignore" style="width: 120px;">
							</td>
							<td align="center" class="value">
								<input id="ffqkd" name="ffqkds" class="mytxt" ignore="ignore" dataType="d">
							</td>
							<td align="center" class="value">
								<input id="ffqzl" name="ffqzls" class="mytxt" ignore="ignore" dataType="d">
							</td>
						    <td align="center" class="value">
						        <div id="f_div_nprocess" class="f_div_nprocess"></div>
						    </td>
							<td align="center" class="value">
								<input id="fnote" name="fnotes" class="mytxt" ignore="ignore">
							</td>
						</tr>
					</table>
		</div>
	</body>